<?php

namespace App\Utils;

class ShortUrl
{
    public const CACHE_KEY_PREFIX = 'short_url:';

    public static function make($url)
    {
        $code = uniqid();
        \Cache::set(self::CACHE_KEY_PREFIX . $code, $url);

        return config('app.url') . '/short/' . $code;
    }

    public static function getRawUrl($code)
    {
        return \Cache::get(self::CACHE_KEY_PREFIX . $code, '');
    }
}
